package com.example.composedialogdemo.dialog

import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.dp

/**
 * @author: njb
 * @date:   2025/8/16 20:37
 * @desc:   描述
 */
@Composable
fun LocationDialog(
    showDialog: Boolean,
    onDismiss:() -> Unit,
    onConfirm:() -> Unit
){
    if(showDialog){
        AlertDialog(
            onDismissRequest = { onDismiss },
            shape = RoundedCornerShape(6.dp),
            title = { Text(text = "开启位置服务") },
            text = {Text(text = "这将意味着，我们会给您提供精准的位置服务，并且您将接受关于您订阅的位置信息")},
            confirmButton = {
                TextButton(
                    onClick = {
                        onConfirm()
                        onDismiss()
                    }
                ) {
                Text( text = "同意")
                }
            },
            dismissButton = {
                TextButton(
                    onClick = onDismiss
                ) {
                    Text(text = "取消")
                }
            }
        )
    }
}